<?php

define("ARRAY_DIR", dirname(__FILE__) . DIRECTORY_SEPARATOR);

function isArrayExist($name)
{
	return file_exists(ARRAY_DIR . $name);
}

function load_array_dump($name) {
    $fp = fopen(ARRAY_DIR . $name,"r");
    $content = fread($fp,filesize(ARRAY_DIR . $name));
    fclose($fp);
	$compress = $content[0];
	$data = ( $compress == '0' || $compress == '1' ) ? substr($content, 1) : $content;
	$array = array();
	if($compress !== '0') {
		eval('$array=' . gzuncompress(stripslashes($data)) .';'); 
	} else {
		eval('$array='. stripslashes($data) .';');
	}
		
    return($array);
}
 
function save_array_dump($name, $array, $compress = 0) {
	$dump = $compress;
    $dump .= addslashes($compress == 1 ? gzcompress(var_export($array,true),9)
										: var_export($array,true));
    $fp = fopen(ARRAY_DIR . $name, "wb+");
    fwrite($fp, $dump);
    fclose($fp);
}
?>